<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "{{%role}}".
 *
 * @property integer $id
 * @property string $name
 * @property string $mark
 * @property string $create_at
 */
class Role extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%role}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['name'], 'required'],
            [['create_at'], 'safe'],
            [['name'], 'string', 'max' => 50],
            [['mark'], 'string', 'max' => 500]
        ];
    }

    public function beforeSave($insert)
    {
        if($this->isNewRecord){
            $this->create_at = date('Y-m-d H:i:s');
        }
        return parent::beforeSave($insert); // TODO: Change the autogenerated stub
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'name' => Yii::t('app', '角色名称'),
            'mark' => Yii::t('app', '角色备注'),
            'create_at' => Yii::t('app', '创建时间'),
        ];
    }
}
